package com.li.hello.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器实例 [/**] 对所有请求都拦截
        registry.addInterceptor(new FirstInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/toLogin", "/login", "/loginOut");//不拦截的链接
        //...注册多个拦截器依次执行
    }
}
